﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;
using System.IO.IsolatedStorage;
using System.Runtime.InteropServices;
using WindowsPhoneApplication1.ServiceReference1;

namespace WindowsPhoneApplication1
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }


        private void rectangle1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/LoginPage.xaml", UriKind.Relative));

        }


        private void rectangle3_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

            IsolatedStorageSettings trkData = IsolatedStorageSettings.ApplicationSettings;

            if (!trkData.Contains("sourcePg"))
                trkData.Add("sourcePg", "srcByLoc");
            else
                trkData["sourcePg"] = "srcByLoc";

            trkData.Save();
            
            NavigationService.Navigate(new Uri("/mapPage.xaml", UriKind.RelativeOrAbsolute));
        }

        private void rectangle4_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            NavigationService.Navigate(new Uri("/searchPage.xaml", UriKind.RelativeOrAbsolute));
        }

        private void rectangle5_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            NavigationService.Navigate(new Uri("/recommendedPage.xaml", UriKind.RelativeOrAbsolute));
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {}

        private void rectangle8_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            NavigationService.Navigate(new Uri("/trackReports.xaml", UriKind.RelativeOrAbsolute));
        }

        private void PhoneApplicationPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to exit?", "Exit?", MessageBoxButton.OKCancel);
            if (messageBoxResult != MessageBoxResult.OK)
                e.Cancel = true;
        }
    }
}